package com.unitechs.trap.write.webapi.controller;

import com.unitechs.trap.common.pojo.trap.entity.CountData;
import com.unitechs.trap.write.service.*;
import com.unitechs.trap.write.webapi.restful.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "Excel数据批量写入数据库")
@Slf4j
@RequestMapping("/write")
public class WriteAllDataController {

    @Autowired
    private IAllDataService allDataService;

    @PostMapping("/all")
    @ApiOperation("写入所有数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "Excel文件地址及文件名",name = "url",example = "F:\\model\\A.xls"),
            @ApiImplicitParam(value = "公司名称英文编码",name = "coName",example = "AL"),
            @ApiImplicitParam(value = "对应版本",name = "version",example = "A")
    })
    public JsonResult<CountData> writeAll(String url, String coName, String version){
        CountData countData = allDataService.start(url, coName,version);
        return JsonResult.ok(countData);
    }

}
